function validateCpf(form) {
        var bValid = true;
        var focusField = null;
        var i = 0;
        var fields = new Array();
        var formName = form.getAttributeNode("name");


        oCpf = eval('new ' + formName.value + '_cpf()');

        for (x in oCpf) {
            var field = form[oCpf[x][0]];
            if ((field.type == 'text') &&
                (field.value.length > 0) &&
                field.disabled == false) {
                if (!ValidaCPF(field)) {
                    if (i == 0) {
                        focusField = field;
                    }
                    fields[i++] = oCpf[x][1];
                    bValid = false;
                }
            }
        }
        if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
        }
        return bValid;
    }
    
function validateCnpj(form) {
        var bValid = true;
        var focusField = null;
        var i = 0;
        var fields = new Array();
        var formName = form.getAttributeNode("name");


        oCnpj = eval('new ' + formName.value + '_cnpj()');

        for (x in oCnpj) {
            var field = form[oCnpj[x][0]];
            if ((field.type == 'text') &&
                (field.value.length > 0) &&
                field.disabled == false) {
                if (!ValidaCNPJ(field)) {
                    if (i == 0) {
                        focusField = field;
                    }
                    fields[i++] = oCnpj[x][1];
                    bValid = false;
                }
            }
        }
        if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
        }
        return bValid;
    }
    
function validateCtps(form) {
        var bValid = true;
        var focusField = null;
        var i = 0;
        var fields = new Array();
        var formName = form.getAttributeNode("name");


        oCtps = eval('new ' + formName.value + '_ctps()');

        for (x in oCtps) {
            var field = form[oCtps[x][0]];
            if ((field.type == 'text') &&
                (field.value.length > 0) &&
                field.disabled == false) {
                if (!ValidaCTPS(field)) {
                    if (i == 0) {
                        focusField = field;
                    }
                    fields[i++] = oCtps[x][1];
                    bValid = false;
                }
            }
        }
        if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
        }
        return bValid;
    }
    
function validateCep(form) {
        var bValid = true;
        var focusField = null;
        var i = 0;
        var fields = new Array();
        var formName = form.getAttributeNode("name");


        oCep = eval('new ' + formName.value + '_cep()');

        for (x in oCep) {
            var field = form[oCep[x][0]];
            if ((field.type == 'text') &&
                (field.value.length > 0) &&
                field.disabled == false) {
                if (!ValidaCEP(field)) {
                    if (i == 0) {
                        focusField = field;
                    }
                    fields[i++] = oCep[x][1];
                    bValid = false;
                }
            }
        }
        if (fields.length > 0) {
            focusField.focus();
            alert(fields.join('\n'));
        }
        return bValid;
    }
    
function validateDateRange(form) {
        var isValid = true;
        var focusField = null;
        var i = 0;
        var fields = new Array();
        var formName = form.getAttributeNode("name");


        oDateRange = eval('new ' + formName.value + '_dateRange()');

        for (x in oDateRange) {
            var field = form[oDateRange[x][0]];

            if (field.type == 'text' &&
                field.disabled == false) {

                var iMinDate = oDateRange[x][2]("mindate");
                var iMaxDate = oDateRange[x][2]("maxdate");
                
                if (field.value.length == 10
                	&& (DataMenor(field.value,iMinDate)
                	|| DataMaior(field.value,iMaxDate))) {
                    if (i == 0) {
                        focusField = field;
                    }
                    fields[i++] = oDateRange[x][1];
                    isValid = false;
                }
            }
        }
        if (fields.length > 0) {
           focusField.focus();
           alert(fields.join('\n'));
        }
        return isValid;
    }